import axios from "axios";
import { Message } from "element-ui";
export default function ajax(url,data={},type='get'){
    return new Promise((resolve,reject)=>{
        let promise
        let qs = require('qs')
        if(type.toLowerCase()=='get')
        {
            promise = axios.get(url,{params:data})
        }else if(type.toLowerCase()=='post')
        {
            promise = axios.post(url,qs.stringify(data))
        }
        promise.then(res=>{
            resolve(res)
        }).catch(err=>{
            Message.error('请求失败')
        })
    })
}